import {createStore,compose,applyMiddleware} from 'redux'
import reducer from './reducer'
import createSagaMiddleware from 'redux-saga'
import TodoSagas from './sagas'

const sagaMiddleware = createSagaMiddleware()

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose;

const enhancer = composeEnhancers(
    applyMiddleware(sagaMiddleware),
  );

//创建store时，用reducer构建初始数据，在创建store时使用一个中渐渐
const store = createStore(reducer, enhancer);

sagaMiddleware.run(TodoSagas)

export default store;

